import scrapy
from Doutu.items import DoutuItem
class Myspider(scrapy.Spider):
    name = 'Doutu'  #一定是唯一
    def start_requests(self):
        start_url = ['http://qq.yh31.com/zjbq/2920180.html','http://qq.yh31.com/zjbq/2920180_2.html']
        for url in start_url:
            yield scrapy.Request(url=url,callback=self.parse)#yield 可以看成return，
            # url 告诉我要去的地址
            #callback   回调函数，获取的界面在那个函数执行，进行下一步操作

    def parse(self,response):
        img_urls = response.xpath('//div[@id="fontzoom"]/p/img')
        a=0
        for img_url in img_urls:
            url = img_url.xpath('@src').extract()
            print(url)
            item = DoutuItem()
            item['name'] = a
            item['addr'] = url[0]
            a+=1
            yield item
